<%--

 Resets a WebQuilt proxy session.
 
 This software is distributed under the Berkeley Software License.
   See "http://guir.cs.berkeley.edu/projects/COPYRIGHT.txt" for details

 author:	Jeffrey Heer 2/01 - jheer@hkn.eecs.berkeley.edu
 updated:	Tara Matthews 7/01 mattews@eecs.berkeley.edu
				Now this file includes survey capabilities.

--%>
<%@ page import="edu.berkeley.guir.webquilt.*"                                   %>
<%@ page import="java.io.*"                                                      %>
<%@ page import="java.util.Date"                                                 %>
<%@ page import="edu.berkeley.guir.webquilt.*"                                   %>


<HTML>
 <HEAD>
	<TITLE>Ending WebQuilt Task</TITLE>
 </HEAD>
 <BODY BGCOLOR="#FFFFFF">
 <H4>WebQuilt Task Finished</H4>
 <TABLE BORDER=0>
   <TR>

<%    

	String strUserID = (String)request.getParameter("formUserID") ;
	String strTaskID = (String) request.getParameter("formTaskID");

%>
<%
    if ( request.getParameter("display") == null ) {
	%> <%@ include file='survey_form.jhtml' %><%
    } else {

	String str1  	= request.getParameter("1");
	String str2  	= request.getParameter("2taskspecific");
	String str3		= request.getParameter("3");
	String str4A = request.getParameter("4A");
	String str4B = request.getParameter("4B");
	String str4C = request.getParameter("4C");
	String str4D = request.getParameter("4D");
	String str4E = request.getParameter("4E");
	String str4F = request.getParameter("4F");
	String str4G = request.getParameter("4G");

	String str5 = new String(request.getParameter("5A") + " " + request.getParameter("5B"));
	String str6 = new String(request.getParameter("6A") + " " +
					 request.getParameter("6B") + " " +
					 request.getParameter("6C") + " " +
					 request.getParameter("6D") + " " +
					 request.getParameter("6E") + " " +
					 request.getParameter("6f") + " " +
				 	request.getParameter("6Other"));
	String str7 = request.getParameter("7");
	String str8 = request.getParameter("8");
	String str9 = new String(request.getParameter("9") + " " + request.getParameter("9Other"));
	String str10 = request.getParameter("10");

	String strFile    = WebQuiltLib.getLogDir() + strTaskID + "-survey.txt";

	FileWriter fwtr = new FileWriter(strFile, true);
	fwtr.write("---------------------------------------\n");
	fwtr.write("%%\n");
	fwtr.write("Time: " + new Date().toString() + "\n");
	fwtr.write("UserID:   " + strUserID + "\n");

	fwtr.write("Responses:\n");
	fwtr.write("1. " + str1 + "\n");
	fwtr.write("2. " + str2 + "\n");
	fwtr.write("3. " + str3 + "\n");

	fwtr.write("4A. " + str4A + "\n");
	fwtr.write("4B. " + str4B + "\n");
	fwtr.write("4C. " + str4C + "\n");
	fwtr.write("4D. " + str4D + "\n");
	fwtr.write("4E. " + str4E + "\n");
	fwtr.write("4F. " + str4F + "\n");
	fwtr.write("4G. " + str4G + "\n");

	fwtr.write("5. " + str5 + "\n");
	fwtr.write("6. " + str6 + "\n");
	fwtr.write("7. " + str7 + "\n");
	fwtr.write("8. " + str8 + "\n");
	fwtr.write("9. " + str9 + "\n");
	fwtr.write("10. " + str10 + "\n");
	fwtr.close();
 
	%> <%@ include file='survey_end.jhtml' %> 
		<% session.invalidate(); %>

<%
    }
%>

   </TR>
  </TABLE>
</BODY>
</HTML>